<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: create by allen.qiang
// +----------------------------------------------------------------------


/**
 * 调度星盘
 * @package  htdocs
 * @subpackage  quanliadmin
 * @author   create by allen.qiang
 */

//引入字典类
quanli_require('module/base/system/itemHandler.class.php');

class pa_schedulingChart {

    public function execute() {

        global $G_PGLOB;

        if(isset($_REQUEST['operFlg']) && is_numeric($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0){

            switch($_REQUEST['operFlg']){

                case 1: //调度星盘列表页

                    $this->schedulingChartList();

                    break;

                default:
                    $G_PGLOB->smarty->assign('msg', '参数错误，请审核后再操作');
                    $G_PGLOB->smarty->display('comm/error.tpl');

            }

        }
    }

    /**
     * 调度星盘列表页
     */
    private  function schedulingChartList(){

        global $G_PGLOB;
        //实例化字典类
        $itemHandler = new itemHandler();

        //配送开始时间数组
        $sendStartTime_array = array();

        //配送结束时间数组
        $sendEndTime_array = array();

        //配送时间参数
        $itemStart_array = array(
            'useFlg' => 1,
            'sortname' => 'itemID',
            'sortorder' => 'ASC'
        );

        //查询字典表信息
        $temp_array = $itemHandler->searchItem( $itemStart_array );

        if( $temp_array ){
            foreach( $temp_array as $val ){
                if($val['itemCategoryID'] == 9){
                    $sendStartTime_array[]['itemName'] = $val['itemName'];
                }

                if($val['itemCategoryID'] == 10){
                    $sendEndTime_array[]['itemName'] = $val['itemName'];
                }

            }
        }

        //保存配送结束时间最晚的时间
        $end_time = '';
        if($sendEndTime_array){
            $result_data = end($sendEndTime_array);
            $end_time = $result_data['itemName'];
        }

        $currentDate = $G_PGLOB->sys_date;//当前时间
        $G_PGLOB->smarty->assign('currentDate',$currentDate);
        $G_PGLOB->smarty->assign_by_ref('sendStartTime_array',$sendStartTime_array);//配送开始时间
        $G_PGLOB->smarty->assign_by_ref('sendEndTime_array',$sendEndTime_array);//配送结束时间
        $G_PGLOB->smarty->assign_by_ref('end_time',$end_time);
        
        $G_PGLOB->smarty->assign('edit_permission', $G_PGLOB->has_permission(20010));

        $G_PGLOB->smarty->display('send/schedulingChart.tpl');
    }


}